package com.huawei.appgallery.wishlist.ui.fragment;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnKeyListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.huawei.appgallery.common.media.api.IImageBrowseProtocol;
import com.huawei.appgallery.common.media.api.IImageBrowseResult;
import com.huawei.appgallery.common.media.api.IMediaSelectProtocol;
import com.huawei.appgallery.common.media.api.IMediaSelectResult;
import com.huawei.appgallery.common.media.api.OriginalMediaBean;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.foundation.ui.framework.widget.PullUpListView;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;
import com.huawei.appgallery.wishlist.ui.fragment.WishAddFragmentProtocol.Request;
import com.huawei.appgallery.wishlist.widget.DetailDescriptionView;
import com.huawei.appgallery.wishlist.widget.EditTextWithListView;
import com.huawei.appgallery.wishlist.widget.WishRoundImageView;
import com.huawei.hms.support.api.entity.pay.HwPayConstant;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import huawei.widget.HwButton;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import o.azb;
import o.bjy;
import o.cfv;
import o.cfw;
import o.HcridSession;
import o.cku;
import o.cvt;
import o.cvv;
import o.cvx;
import o.dbr;
import o.dbx;
import o.dby;
import o.dce.j;
import o.dcg;
import o.dch;
import o.dcp;
import o.dct;
import o.dcv;
import o.dcw;
import o.dgm;
import o.djl;
import o.dmq;
import o.dnx;
import o.dof;
import o.doo;
import o.ContentManager;
import o.epk;
import o.epl;
import o.epv;
import o.eqp;
import o.eqx;
import o.evk;
import o.evx;
import o.ewa;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjc;
import org.json.JSONObject;

public class WishAddFragment extends AppListFragment<WishAddFragmentProtocol> implements o.dcv.b, OnCheckedChangeListener, o.dby.e {
    private View ʳ;
    private Map<String, File> ʴ = new HashMap();
    private int ʹ = 0;
    private EditTextWithListView ʹॱ;
    private View ʻʻ;
    private List<OriginalMediaBean> ʻʼ = new ArrayList();
    private View ʻʽ;
    private String ʻˊ = "";
    private djl ʻˋ;
    private boolean ʼʻ = false;
    private i ʼʼ;
    private int ʼʽ;
    private HwButton ʼˋ;
    private boolean ʽʻ = false;
    private int ʽʼ = 0;
    private dcw ʾˊ;
    private TextWatcher ʾˋ = new TextWatcher(this) {
        final /* synthetic */ WishAddFragment ॱ;

        {
            this.ॱ = r1;
        }

        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (TextUtils.isEmpty(this.ॱ.ꜟॱ.getText().toString()) || TextUtils.isEmpty(this.ॱ.ꜟॱ.getText().toString().trim())) {
                this.ॱ.ʼˋ.setEnabled(false);
            } else {
                this.ॱ.ʼˋ.setEnabled(true);
            }
        }

        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (!TextUtils.isEmpty(this.ॱ.ꜟॱ.getText().toString()) && !TextUtils.isEmpty(this.ॱ.ꜟॱ.getText().toString().trim())) {
                new Handler().postDelayed(new Runnable(this) {
                    final /* synthetic */ AnonymousClass3 ॱ;

                    {
                        this.ॱ = r1;
                    }

                    public void run() {
                        this.ॱ.ॱ.ʿˊ();
                    }
                }, 300);
            } else if (this.ॱ.י != null) {
                this.ॱ.י.ॱॱ();
                this.ॱ.י.ͺ();
            }
        }

        public void afterTextChanged(Editable editable) {
            if (TextUtils.isEmpty(this.ॱ.ꜟॱ.getText().toString()) || TextUtils.isEmpty(this.ॱ.ꜟॱ.getText().toString().trim())) {
                this.ॱ.ʼˋ.setEnabled(false);
            } else {
                this.ॱ.ʼˋ.setEnabled(true);
            }
        }
    };
    private ConcurrentHashMap<String, String> ˊ = new ConcurrentHashMap();
    private boolean ॱॱ = false;
    private boolean ᐝ = false;
    private CheckBox ꜝ;
    private TextView ꜞॱ;
    private EditText ꜟॱ;
    private View ꞌॱ;
    private String[] ﹳ = new String[]{".jpg", ".jpeg", ".png"};
    private View ﹳॱ;
    private View ﹶ;
    private DetailDescriptionView ﹺ;
    private WishAddFragmentProtocol ﾞ;
    private CheckBox ﾞॱ;
    private String ﾟ = "";
    private View ﾟॱ;

    static class a extends fjc<IImageBrowseResult> {
        private String ॱ;

        public /* synthetic */ void ˎ(int i, Object obj) {
            ॱ(i, (IImageBrowseResult) obj);
        }

        public a(String str) {
            this.ॱ = str;
        }

        public void ॱ(int i, IImageBrowseResult iImageBrowseResult) {
            Fragment findFragmentByTag = ((FragmentActivity) ˊ()).ˏॱ().findFragmentByTag(this.ॱ);
            if (findFragmentByTag instanceof WishAddFragment) {
                ((WishAddFragment) findFragmentByTag).ˊ(i, (IMediaSelectResult) iImageBrowseResult);
            }
        }
    }

    class b implements OnKeyListener {
        final /* synthetic */ WishAddFragment ˏ;

        b(WishAddFragment wishAddFragment) {
            this.ˏ = wishAddFragment;
        }

        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            if (i == 4 && keyEvent.getRepeatCount() == 0) {
                dch.ˎ.ˋ("WishAddFragment", "cancel Commit");
                this.ˏ.ᐝ = false;
            }
            return false;
        }
    }

    static class c extends dbr {
        private int ˊ;
        private String ˋ;
        private WeakReference<WishAddFragment> ˎ;
        private int ˏ;
        private String ॱ;
        private e ॱॱ;

        public c(WeakReference<WishAddFragment> weakReference, String str, String str2, int i, int i2, e eVar) {
            this.ˎ = weakReference;
            this.ॱ = str;
            this.ˋ = str2;
            this.ˊ = i;
            this.ˏ = i2;
            this.ॱॱ = eVar;
        }

        public void ˎ(Map<String, String> map, String str, String str2) {
            map.put(str, dof.ˏ(str2));
        }

        public Map<String, String> ˋ() {
            Map<String, String> linkedHashMap = new LinkedHashMap();
            dch.ˎ.ˎ("WishAddFragment", "start genParams...");
            String valueOf = String.valueOf(System.currentTimeMillis());
            ˎ(linkedHashMap, "method", dcg.APIMETHOD);
            ˎ(linkedHashMap, "appName", this.ॱ);
            if (!TextUtils.isEmpty(this.ˋ)) {
                ˎ(linkedHashMap, "desc", this.ˋ);
            }
            ˎ(linkedHashMap, "type", this.ॱॱ.ˎ());
            if (!TextUtils.isEmpty(this.ॱॱ.ˊ())) {
                ˎ(linkedHashMap, "keyword", this.ॱॱ.ˊ());
            }
            ˎ(linkedHashMap, "isAutoInstall", String.valueOf(this.ˊ));
            ˎ(linkedHashMap, "syncToWall", String.valueOf(this.ˏ));
            ˎ(linkedHashMap, "serviceType", this.ॱॱ.ˋ());
            ˎ(linkedHashMap, HwPayConstant.KEY_SIGN, this.ॱॱ.ˏ());
            ˎ(linkedHashMap, "clientPackage", this.ॱॱ.ॱ());
            ˎ(linkedHashMap, "ts", valueOf);
            o.bjy.c ॱ = new bjy(ContentManager.getInstant().getContext()).ॱ();
            ˎ(linkedHashMap, "deviceId", ॱ.ˎ);
            ˎ(linkedHashMap, "deviceIdType", String.valueOf(ॱ.ॱ));
            ˎ(linkedHashMap, "net", this.ॱॱ.ʻ());
            ˎ(linkedHashMap, "code", epl.ॱ().ˎ());
            try {
                ˎ(linkedHashMap, "authorization", epk.ˏ().toJson());
            } catch (Exception e) {
                dch.ˎ.ˊ("WishAddFragment", e.toString());
            }
            return linkedHashMap;
        }

        public boolean ॱ(String str) {
            try {
                if (dch.ˎ.ˎ()) {
                    dch.ˎ.ˎ("WishAddFragment", "start parseResult...");
                }
                int i = new JSONObject(str).getInt("rtnCode");
                if (this.ˎ != null) {
                    WishAddFragment wishAddFragment = (WishAddFragment) this.ˎ.get();
                    if (wishAddFragment != null) {
                        wishAddFragment.ʹ = i;
                    }
                }
                if (i == 0) {
                    return true;
                }
                dch.ˎ.ˏ("WishAddFragment", "uploadWishInfo(), parseResult failed. rtnCode:" + i);
                return false;
            } catch (Exception e) {
                dch.ˎ.ˏ("WishAddFragment", "uploadWishInfo(), parseResult exception " + e.toString());
                return false;
            }
        }

        public String ॱ() {
            return cvx.ˎ("server.store") + "clientApi";
        }
    }

    static class d extends fjc<IMediaSelectResult> {
        private String ˎ;

        public d(String str) {
            this.ˎ = str;
        }

        public void ˎ(int i, IMediaSelectResult iMediaSelectResult) {
            Fragment findFragmentByTag = ((FragmentActivity) ˊ()).ˏॱ().findFragmentByTag(this.ˎ);
            if (findFragmentByTag instanceof WishAddFragment) {
                ((WishAddFragment) findFragmentByTag).ˊ(i, iMediaSelectResult);
            }
        }
    }

    static class e {
        private String ˊ;
        private String ˋ;
        private String ˎ;
        private String ˏ;
        private String ॱ;
        private String ᐝ;

        private e() {
        }

        public String ˎ() {
            return this.ॱ;
        }

        public void ˎ(String str) {
            this.ॱ = str;
        }

        public String ˊ() {
            return this.ˏ;
        }

        public void ˏ(String str) {
            this.ˏ = str;
        }

        public String ˋ() {
            return this.ˎ;
        }

        public void ˊ(String str) {
            this.ˎ = str;
        }

        public String ˏ() {
            return this.ˊ;
        }

        public void ॱ(String str) {
            this.ˊ = str;
        }

        public String ॱ() {
            return this.ˋ;
        }

        public void ˋ(String str) {
            this.ˋ = str;
        }

        public String ʻ() {
            return this.ᐝ;
        }

        public void ʽ(String str) {
            this.ᐝ = str;
        }
    }

    class i extends SafeBroadcastReceiver {
        final /* synthetic */ WishAddFragment ॱ;

        private i(WishAddFragment wishAddFragment) {
            this.ॱ = wishAddFragment;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            if (intent == null || intent.getData() == null) {
                dch.ˎ.ˊ("WishAddFragment", "error intent");
                return;
            }
            String schemeSpecificPart = intent.getData().getSchemeSpecificPart();
            if (TextUtils.isEmpty(schemeSpecificPart)) {
                dch.ˎ.ˊ("WishAddFragment", "error packageName");
                return;
            }
            String action = intent.getAction();
            dch.ˎ.ˋ("WishAddFragment", " installedApkChangedReceiver, action = " + action + "," + "packageName:" + schemeSpecificPart);
            if ("android.intent.action.PACKAGE_ADDED".equals(action)) {
                PackageInfo ˏ = dnx.ˏ(schemeSpecificPart, ContentManager.getInstant().getContext());
                if (ˏ != null) {
                    this.ॱ.ˊ.put(ˏ.packageName, ˏ.applicationInfo.loadLabel(ContentManager.getInstant().getContext().getPackageManager()).toString());
                }
            } else if (!"android.intent.action.PACKAGE_REMOVED".equals(action)) {
            } else {
                if (intent.getBooleanExtra("android.intent.extra.REPLACING", false)) {
                    dch.ˎ.ˋ("WishAddFragment", "replace app,receive REMVED Broadcast.do nothing");
                } else {
                    this.ॱ.ˊ.remove(schemeSpecificPart);
                }
            }
        }
    }

    public void ˏ(Bundle bundle) {
        this.ﾞ = (WishAddFragmentProtocol) ˆ();
        if (this.ﾞ != null && this.ﾞ.ॱ() != null) {
            this.ﾟ = ((Request) this.ﾞ.ॱ()).ˌ();
            this.ʻˊ = ((Request) this.ﾞ.ॱ()).ˋᐝ();
            ॱˋ(true);
            this.ʾˊ = new dcw(new o.dcw.c(this) {
                final /* synthetic */ WishAddFragment ॱ;

                {
                    this.ॱ = r1;
                }

                public void ˏ(ConcurrentHashMap<String, String> concurrentHashMap) {
                    this.ॱ.ˊ = concurrentHashMap;
                    this.ॱ.ॱॱ = true;
                    this.ॱ.ˊʻ();
                    if (this.ॱ.ᐝ && this.ॱ.ʾ()) {
                        this.ॱ.ٴ();
                    }
                }
            });
            this.ʾˊ.execute(new Void[0]);
            super.ˏ(bundle);
            Resources ᐝॱ = ᐝॱ();
            if (ᐝॱ != null) {
                this.ʼʽ = ᐝॱ.getDimensionPixelSize(o.dce.d.ˋ);
            }
        }
    }

    private void ˊʻ() {
        this.ʼʼ = new i();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
        intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
        intentFilter.addDataScheme(HiAnalyticsConstant.BI_KEY_PACKAGE);
        ContentManager.getInstant().getContext().registerReceiver(this.ʼʼ, intentFilter);
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        ˊ(this.ﹶ);
        this.ʼˋ = (HwButton) ˋ.findViewById(o.dce.e.ॱʻ);
        this.ʼˋ.getLayoutParams().width = epv.ˎ(ॱˋ()) / 2;
        this.ʼˋ.setOnClickListener(new evx(this) {
            final /* synthetic */ WishAddFragment ˊ;

            {
                this.ˊ = r1;
            }

            public void ˋ(View view) {
                if (doo.ˊ(this.ˊ.ॱˊ())) {
                    this.ˊ.ʹ = 0;
                    this.ˊ.ʻˋ = new djl(this.ˊ.ॱˊ());
                    this.ˊ.ʻˋ.setCanceledOnTouchOutside(false);
                    this.ˊ.ʻˋ.ˋ(this.ˊ.ॱ(j.ʿ));
                    this.ˊ.ʻˋ.setOnKeyListener(new b(this.ˊ));
                    this.ˊ.ʻˋ.show();
                    if (this.ˊ.ॱॱ) {
                        this.ˊ.ٴ();
                        return;
                    }
                    this.ˊ.ᐝ = true;
                    dch.ˎ.ˋ("WishAddFragment", "InstalledList is no ready");
                    return;
                }
                evk.ॱ(ContentManager.getInstant().getContext().getString(j.ˋ), 0).ˋ();
            }
        });
        if (TextUtils.isEmpty(this.ﾟ) || TextUtils.isEmpty(this.ﾟ.trim())) {
            this.ʼˋ.setEnabled(false);
        } else {
            if (this.ﾟ.length() > 48) {
                this.ﾟ = this.ﾟ.substring(0, 48);
            }
            this.ꜟॱ.setText(this.ﾟ);
            this.ꜟॱ.setSelection(this.ﾟ.length());
            this.ʼˋ.setEnabled(true);
            ʿˊ();
        }
        this.ꜟॱ.addTextChangedListener(this.ʾˋ);
        this.ꜞॱ.setText(ॱ(j.ˊॱ).toUpperCase(Locale.US) + " (" + ॱ(j.ˊˊ) + ")");
        return ˋ;
    }

    public int ߵ() {
        return o.dce.i.ॱˊ;
    }

    public void ᵔ() {
        this.ͺˎ = (PullUpListView) this.ॱˍ.findViewById(o.dce.e.ॱॱ);
        this.ͺˎ.setNeedFootView(false);
        this.ﹳॱ = this.ᴵ.inflate(o.dce.i.ॱᐝ, null);
        azb.ˏ(this.ﹳॱ);
        this.ꞌॱ = this.ᴵ.inflate(o.dce.i.ˋॱ, null);
        azb.ˏ(this.ꞌॱ);
        this.ﹶ = this.ᴵ.inflate(o.dce.i.ͺ, null);
        azb.ˏ(this.ﹶ);
        this.ꜟॱ = (EditText) this.ﹳॱ.findViewById(o.dce.e.ʼˋ);
        this.ꜝ = (CheckBox) this.ꞌॱ.findViewById(o.dce.e.ॱͺ);
        this.ꜝ.setChecked(eqp.ᐝ());
        if (UserSession.getInstance().isUserMinor()) {
            this.ꜝ.setChecked(false);
            this.ꜝ.setVisibility(8);
        }
        this.ꜞॱ = (TextView) this.ﹳॱ.findViewById(o.dce.e.ﾟ);
        this.ﹺ = (DetailDescriptionView) this.ﹶ.findViewById(o.dce.e.ᐝˊ);
        this.ʳ = this.ᴵ.inflate(o.dce.i.ᐝॱ, null);
        this.ﾞॱ = (CheckBox) this.ʳ.findViewById(o.dce.e.ॱʼ);
        if (dbx.ˏ().ॱ()) {
            this.ʳ.setVisibility(0);
            this.ﾞॱ.setChecked(dct.ˏ().ॱ());
            this.ﾞॱ.setOnCheckedChangeListener(this);
        } else {
            this.ʳ.setVisibility(8);
        }
        this.ﹺ = (DetailDescriptionView) this.ﹶ.findViewById(o.dce.e.ᐝˊ);
        this.ʹॱ = (EditTextWithListView) this.ﹺ.findViewById(o.dce.e.ॱˎ);
        this.ʹॱ.setHint(ContentManager.getInstant().getContext().getResources().getString(j.ॱ, new Object[]{Integer.valueOf(150)}));
        this.ʹॱ.setOnFocusChangeListener(new OnFocusChangeListener(this) {
            final /* synthetic */ WishAddFragment ˎ;

            {
                this.ˎ = r1;
            }

            public void onFocusChange(View view, boolean z) {
                if (z) {
                    this.ˎ.ʼʻ = z;
                    this.ˎ.ʽʻ = false;
                    this.ˎ.ॱʾ();
                }
            }
        });
        this.ꜟॱ.setOnFocusChangeListener(new OnFocusChangeListener(this) {
            final /* synthetic */ WishAddFragment ˏ;

            {
                this.ˏ = r1;
            }

            public void onFocusChange(View view, boolean z) {
                if (z) {
                    this.ˏ.ʽʻ = z;
                    this.ˏ.ʼʻ = false;
                    this.ˏ.ˏॱ(0);
                }
            }
        });
        this.ʹॱ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ WishAddFragment ˏ;

            {
                this.ˏ = r1;
            }

            public void onClick(View view) {
                if (this.ˏ.ʼʻ) {
                    this.ˏ.ॱʾ();
                }
            }
        });
        if (this.ͺˎ != null) {
            this.ͺˎ.addHeaderView(this.ﹳॱ);
            this.ͺˎ.addHeaderView(this.ꞌॱ);
            this.ͺˎ.addHeaderView(this.ﹶ);
            if (dbx.ˏ().ॱ()) {
                this.ͺˎ.addHeaderView(this.ʳ);
            }
            ߺ();
        }
    }

    public boolean ﹺ() {
        return false;
    }

    public void ˎˎ() {
        if (this.ʻˋ != null && this.ʻˋ.isShowing()) {
            this.ᐝ = false;
            this.ʻˋ.dismiss();
        }
        if (this.ʾˊ != null) {
            this.ʾˊ.cancel(true);
        }
        if (this.ʼʼ != null) {
            ContentManager.getInstant().getContext().unregisterReceiver(this.ʼʼ);
        }
        this.ʻʼ.clear();
        this.ʴ.clear();
        super.ˎˎ();
    }

    private void ٴ() {
        String str;
        int i;
        int i2 = 1;
        String trim = String.valueOf(this.ꜟॱ.getText()).trim();
        String valueOf = String.valueOf(this.ﹺ.ˎ());
        for (Entry value : this.ˊ.entrySet()) {
            if (((String) value.getValue()).equalsIgnoreCase(trim)) {
                dch.ˎ.ˋ("WishAddFragment", "the app has been installed");
                if (this.ʻˋ != null && this.ʻˋ.isShowing()) {
                    this.ʻˋ.dismiss();
                }
                evk.ॱ(ContentManager.getInstant().getContext().getResources().getString(j.ʾ), 0).ˋ();
                return;
            }
        }
        this.ᐝ = false;
        if (TextUtils.isEmpty(valueOf) || TextUtils.isEmpty(valueOf.trim())) {
            str = "";
        } else {
            str = valueOf;
        }
        if (this.ꜝ.isChecked()) {
            i = 1;
        } else {
            i = 0;
        }
        if (!this.ﾞॱ.isChecked()) {
            i2 = 0;
        }
        ˎ(trim, str, i, i2);
    }

    private void י() {
        fjb ˎ = fho.ˏ().ˋ("Media").ˎ("MediaSelect");
        IMediaSelectProtocol iMediaSelectProtocol = (IMediaSelectProtocol) ˎ.ˊ();
        iMediaSelectProtocol.setMediaType("image");
        iMediaSelectProtocol.setMimeTyes(new String[]{"image/jpeg", "image/jpg", "image/png"});
        iMediaSelectProtocol.setMaxSelectSize(3);
        iMediaSelectProtocol.setMaxSelectFileSize(10485760);
        iMediaSelectProtocol.setSelectedImages(this.ʻʼ);
        fiu.ˊ().ॱ(ॱˋ(), ˎ, new d(ʽ()));
    }

    private void ʼ(int i) {
        fjb ˎ = fho.ˏ().ˋ("Media").ˎ("ImageBrowse");
        IImageBrowseProtocol iImageBrowseProtocol = (IImageBrowseProtocol) ˎ.ˊ();
        iImageBrowseProtocol.setMediaType("image");
        iImageBrowseProtocol.setMimeTyes(new String[]{"image/jpeg", "image/jpg", "image/png"});
        iImageBrowseProtocol.setMaxSelectSize(3);
        iImageBrowseProtocol.setMaxSelectFileSize(10485760);
        iImageBrowseProtocol.setBrowseStartPostion(i);
        iImageBrowseProtocol.setSelectedImages(this.ʻʼ);
        iImageBrowseProtocol.setBrowseImages(this.ʻʼ);
        fiu.ˊ().ॱ(ॱˋ(), ˎ, new a(ʽ()));
    }

    private void ˊ(int i, IMediaSelectResult iMediaSelectResult) {
        if (i == -1) {
            if (iMediaSelectResult != null) {
                this.ʻʼ = iMediaSelectResult.getSelectedMedias();
                ˎ(this.ʻʼ);
            }
        } else if (i == 0) {
            ˎ(this.ʻʼ);
        }
    }

    private void ॱॱ(int i) {
        this.ʻʼ.remove(i);
        ˎ(this.ʻʼ);
    }

    private void ˎ(String str, String str2, int i, int i2) {
        e eVar = new e();
        eVar.ˎ(this.ʻˊ);
        eVar.ˏ(this.ﾟ);
        int ˎ = dgm.ˎ(ॱˋ());
        eVar.ˊ(String.valueOf(ˎ));
        eVar.ॱ(ʽ(ˎ));
        eVar.ˋ(ॱˋ().getPackageName());
        eVar.ʽ(String.valueOf(doo.ˏ(ॱˋ())));
        dmq.ˏ.ॱ(new dcv(this.ʴ, new c(new WeakReference(this), str, str2, i, i2, eVar), this));
    }

    private String ʽ(int i) {
        String ˏ = HcridSession.ˋ().ˏ(i);
        if (!TextUtils.isEmpty(ˏ)) {
            return ˏ;
        }
        cvt ˎ = cvv.ˎ();
        ˎ.setServiceType_(i);
        ResponseBean ॱ = cfw.ॱ(ˎ);
        if ((ॱ instanceof StartupResponse) && ॱ.getRtnCode_() == 0 && ॱ.getResponseCode() == 0) {
            ((StartupResponse) ॱ).ˎ(ˎ);
        }
        return HcridSession.ˋ().ˏ(i);
    }

    private void ˊ(View view) {
        if (view != null) {
            TextView textView = (TextView) view.findViewById(o.dce.e.ˎˏ);
            textView.setText(ContentManager.getInstant().getContext().getResources().getString(j.ͺ, new Object[]{Integer.valueOf(3)}));
            textView.setOnClickListener(new evx(this) {
                final /* synthetic */ WishAddFragment ˋ;

                {
                    this.ˋ = r1;
                }

                public void ˋ(View view) {
                    this.ˋ.י();
                }
            });
            this.ﾟॱ = view.findViewById(o.dce.e.ꞌ);
            this.ʻʻ = view.findViewById(o.dce.e.ﾞ);
            this.ʻʽ = view.findViewById(o.dce.e.ﹳ);
        }
    }

    private void ˋ(View view) {
        if (view != null) {
            view.setVisibility(0);
            ImageView imageView = (ImageView) view.findViewById(o.dce.e.ˌ);
            imageView.setVisibility(0);
            ((WishRoundImageView) view.findViewById(o.dce.e.ᐝᐝ)).setImageResource(o.dce.c.ʽ);
            view.findViewById(o.dce.e.ـ).setVisibility(8);
            imageView.setOnClickListener(new evx(this) {
                final /* synthetic */ WishAddFragment ˊ;

                {
                    this.ˊ = r1;
                }

                public void ˋ(View view) {
                    this.ˊ.י();
                }
            });
        }
    }

    private void ˎ(List<OriginalMediaBean> list) {
        int size = list == null ? 0 : list.size();
        this.ʴ.clear();
        this.ʻʻ.setVisibility(8);
        this.ʻʽ.setVisibility(8);
        if (size == 0) {
            ˋ(this.ﾟॱ);
        }
        if (size == 1) {
            ˎ(this.ﾟॱ, 0, (OriginalMediaBean) list.get(0));
            ˋ(this.ʻʻ);
        } else if (size == 2) {
            ˎ(this.ﾟॱ, 0, (OriginalMediaBean) list.get(0));
            ˎ(this.ʻʻ, 1, (OriginalMediaBean) list.get(1));
            ˋ(this.ʻʽ);
        } else if (size == 3) {
            ˎ(this.ﾟॱ, 0, (OriginalMediaBean) list.get(0));
            ˎ(this.ʻʻ, 1, (OriginalMediaBean) list.get(1));
            ˎ(this.ʻʽ, 2, (OriginalMediaBean) list.get(2));
        }
    }

    private void ˎ(View view, final int i, OriginalMediaBean originalMediaBean) {
        view.setVisibility(0);
        view.findViewById(o.dce.e.ـ).setVisibility(0);
        eqx.ˎ((WishRoundImageView) view.findViewById(o.dce.e.ᐝᐝ), originalMediaBean.ʽ());
        view.findViewById(o.dce.e.ˌ).setOnClickListener(new evx(this) {
            final /* synthetic */ WishAddFragment ॱ;

            public void ˋ(View view) {
                this.ॱ.ʼ(i);
            }
        });
        view.findViewById(o.dce.e.ـ).setOnClickListener(new evx(this) {
            final /* synthetic */ WishAddFragment ॱ;

            public void ˋ(View view) {
                this.ॱ.ॱॱ(i);
            }
        });
        ˏ(i, originalMediaBean);
    }

    private void ˏ(int i, OriginalMediaBean originalMediaBean) {
        if (i == 0) {
            this.ʴ.put("screenshot1", new File(originalMediaBean.ʽ()));
        } else if (i == 1) {
            this.ʴ.put("screenshot2", new File(originalMediaBean.ʽ()));
        } else if (i == 2) {
            this.ʴ.put("screenshot3", new File(originalMediaBean.ʽ()));
        }
    }

    public void ˏ(boolean z) {
        if (this.ʻˋ != null && this.ʻˋ.isShowing()) {
            this.ʻˋ.dismiss();
        }
        if (z && ॱˋ() != null) {
            new dcp().ॱ();
            ˎ(ॱˋ());
        } else if (!ʾ()) {
        } else {
            if (50101 == this.ʹ) {
                evk.ˏ(ॱ(j.ˈ));
            } else if (50103 == this.ʹ) {
                evk.ˏ(ॱ(j.ˋˊ));
            } else if (50104 == this.ʹ) {
                evk.ˏ(ॱ(j.ˊᐝ));
            } else {
                evk.ˏ(ॱ(j.ˊ));
            }
        }
    }

    private void ˎ(Context context) {
        cku ˋ = cku.ˋ(context.getResources().getString(j.ॱˊ), context.getResources().getString(j.ˊˋ));
        ˋ.ˎ(-2, 8);
        ˋ.ˎ(context);
        ˋ.ॱ(-1, context.getResources().getString(j.ʻ));
        ˋ.ˋ(new ewa(this) {
            final /* synthetic */ WishAddFragment ˎ;

            {
                this.ˎ = r1;
            }

            public void ˏ(Activity activity, DialogInterface dialogInterface, int i) {
                if (this.ˎ.ॱˋ() != null) {
                    this.ˎ.ॱˋ().setResult(-1, null);
                    this.ˎ.ॱˋ().finish();
                }
            }

            public void ˊ(Activity activity, DialogInterface dialogInterface) {
                if (this.ˎ.ॱˋ() != null) {
                    this.ˎ.ॱˋ().setResult(-1, null);
                    this.ˎ.ॱˋ().finish();
                }
            }
        });
    }

    public void ॱ(int i, int i2, Intent intent) {
        super.ॱ(i, i2, intent);
        fiu.ˊ().ˎ(i, i2, intent);
    }

    public void ˋ(TaskFragment taskFragment, List<cvt> list) {
        if (this.ꜟॱ != null) {
            list.add(cfv.ˎ("wishsearch|" + this.ꜟॱ.getText().toString().trim(), "", dgm.ˎ(ॱˋ()), 1));
        }
    }

    public boolean ˊ(TaskFragment taskFragment, com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment.b bVar) {
        if (this.י != null) {
            this.י.ॱॱ();
        }
        if (this.ꜟॱ != null) {
            Object trim = this.ꜟॱ.getText().toString().trim();
            if (TextUtils.isEmpty(trim) || TextUtils.isEmpty(trim.trim())) {
                ˎ(this.ͺˎ, 0);
                return false;
            }
        }
        super.ˊ(taskFragment, bVar);
        ˎ(this.ͺˎ, 0);
        if (this.ꜟॱ != null && this.ʽʻ) {
            this.ꜟॱ.setFocusable(true);
            this.ꜟॱ.setFocusableInTouchMode(true);
            this.ꜟॱ.setCursorVisible(true);
            this.ꜟॱ.requestFocus();
        }
        if (this.ʼʻ) {
            this.ʹॱ.setFocusable(true);
            this.ʹॱ.setFocusableInTouchMode(true);
            this.ʹॱ.setCursorVisible(true);
            this.ʹॱ.requestFocus();
        }
        return false;
    }

    public void ˋ(@NonNull Bundle bundle) {
        super.ˋ(bundle);
        if (this.ꜟॱ != null && this.ﹺ != null) {
            bundle.putString("input_name", String.valueOf(this.ꜟॱ.getText()));
            bundle.putString("input_desc", String.valueOf(this.ﹺ.ˎ()));
        }
    }

    public void ॱˊ(@Nullable Bundle bundle) {
        super.ॱˊ(bundle);
        if (bundle != null && this.ꜟॱ != null && this.ﹺ != null) {
            this.ꜟॱ.setText(bundle.getString("input_name"));
            this.ﹺ.setText(bundle.getString("input_desc"));
            ˎ(this.ʻʼ);
        }
    }

    private void ߺ() {
        this.ͺˎ.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener(this) {
            final /* synthetic */ WishAddFragment ˋ;

            {
                this.ˋ = r1;
            }

            public void onGlobalLayout() {
                this.ˋ.ॱʾ();
            }
        });
    }

    private void ˏॱ(int i) {
        if (this.ﾟॱ != null && this.ʽʼ != i) {
            LayoutParams layoutParams = (LayoutParams) this.ﾟॱ.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.bottomMargin = i;
                this.ʽʼ = i;
                this.ﾟॱ.setLayoutParams(layoutParams);
            }
        }
    }

    private void ॱʾ() {
        Resources ᐝॱ = ᐝॱ();
        if (ᐝॱ != null) {
            if (this.ʼʻ && ᐝॱ.getConfiguration().orientation == 1) {
                if (this.י == null || this.י.ˊॱ() <= 0) {
                    Rect rect = new Rect();
                    this.ͺˎ.getWindowVisibleDisplayFrame(rect);
                    if (this.ͺˎ.getRootView().getHeight() - rect.bottom > epv.ˎ(ᐝॱ)) {
                        ˏॱ(this.ʼʽ);
                        return;
                    }
                }
                ˏॱ(0);
                return;
            }
            ˏॱ(0);
        }
    }

    public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
        if (compoundButton.getId() == o.dce.e.ॱʼ) {
            dct.ˏ().ॱ(z);
            if (z) {
                ॱـ();
            }
        }
    }

    private void ॱـ() {
        if (!dct.ˏ().ˊ()) {
            dby ˏ = dby.ˏ(ॱˊ().getString(j.ˏ));
            ˏ.ˋ((o.dby.e) this);
            ˏ.ˎ(ॱˊ());
        }
    }

    public void ˋ(boolean z) {
        if (z) {
            dct.ˏ().ˋ(true);
        }
    }

    public void ॱ() {
        this.ﾞॱ.setChecked(false);
        dct.ˏ().ॱ(false);
    }
}
